﻿<%@ Page Title="Collection Entry" Language="C#" MasterPageFile="~/AuditBillingMaster.master" AutoEventWireup="true" CodeFile="Collection.aspx.cs" Inherits="Collection" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script src="../JS/Forms/jsCollection.js" type="text/javascript"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cntList" runat="Server">
    <asp:HiddenField runat="server" ID="hdnExportToExcelFilePath" ClientIDMode="Static" />
    <input type="hidden" id="hdnCollectionID" runat="server" value="0" clientidmode="Static" />
    <asp:HiddenField ID="hdnInvoiceID" Value="0" runat="server" ClientIDMode="Static" />

    <div class="pagecontent">
        <div class="headercontainer">
            <div class="headertextcontainer halfpanel">
                Collection
            </div>
            <div class="headerbuttoncontainer halfpanel">
                <a id="A1" href='javascript:void(0);' onclick="toggle_TopContainer();" tabindex="12" class="headersearchbutton" title="Toggle Search Panel" runat="server">Search</a>&nbsp;&nbsp;
                <a runat="server" href='javascript:void(0);' id="lnkAdd" tabindex="12" clientidmode="Static" class="headeraddbutton" title="Add Collection"
                    onclick='javascript:ShowEditDiv(0,this);'>Add Collection</a>
                <a href="Collection.aspx?Excel" class="headerexportbutton" tabindex="13">Export To Excel</a>

            </div>
        </div>
        <div id="divTopContainer" class="topcontainerwrapper">
            <div class="topcontainerSmall" onkeypress="javascript:return fireDefaultButton(event, 'btnSearch')">
                <div class="halfpanel">
                    <div class="row">
                        <asp:DropDownList ID="cboCompany" ClientIDMode="Static" runat="server" TabIndex="2" multiple="multiple" placeholder="All Companies"
                            CssClass="searchCntrl" Width="70%">
                        </asp:DropDownList>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                        <asp:DropDownList ID="cboContract" ClientIDMode="Static" runat="server" TabIndex="4" multiple="multiple" placeholder="All Contracts"
                            CssClass="searchCntrl" Width="70%">
                        </asp:DropDownList>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                        <asp:TextBox ID="txtInvoiceNo" runat="server" ClientIDMode="Static" MaxLength="50"
                            TabIndex="6" CssClass="searchCntrl" placeholder="Enter Invoice #"></asp:TextBox>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                        <div class="labelPad4">
                            Invoice Start Date
                        </div>
                        <div class="value">
                            <div class="input-append date">
                                <asp:TextBox ID="txtInvoiceStartDate" runat="server" ClientIDMode="Static" MaxLength="50"
                                    onclick="show_DateCalender('txtInvoiceStartDate');" TabIndex="8" CssClass="dateinput"
                                    ReadOnly="true" placeholder="dd/mm/yyyy" onkeydown="javascript:return clearDates(event);"></asp:TextBox>
                                <span class="add-on" id="Span8" onclick="show_DateCalender('txtInvoiceStartDate');" style="float: right"><i
                                    class="icon-th"></i></span>
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                        <div class="labelPad4">
                            Invoice End Date
                        </div>
                        <div class="value">
                            <div class="input-append date">
                                <asp:TextBox ID="txtInvoiceEndDate" runat="server" ClientIDMode="Static" MaxLength="50"
                                    onclick="show_DateCalender('txtInvoiceEndDate');" TabIndex="10" CssClass="dateinput"
                                    ReadOnly="true" placeholder="dd/mm/yyyy" onkeydown="javascript:return clearDates(event);"></asp:TextBox>
                                <span class="add-on" id="Span5" onclick="show_DateCalender('txtInvoiceEndDate');" style="float: right"><i
                                    class="icon-th"></i></span>
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                    </div>
                </div>
                <div class="halfpanel">
                    <div class="row">
                        <asp:DropDownList ID="cboClient" ClientIDMode="Static" runat="server" TabIndex="3" multiple="multiple" placeholder="All Clients"
                            CssClass="searchCntrl" Width="70%">
                        </asp:DropDownList>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                        <asp:DropDownList ID="cboPaymentMode" ClientIDMode="Static" runat="server" TabIndex="5" multiple="multiple" placeholder="All Payment Modes"
                            CssClass="searchCntrl" Width="70%">
                        </asp:DropDownList>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                        <asp:TextBox ID="txtContractNo" runat="server" ClientIDMode="Static" MaxLength="50"
                            TabIndex="7" CssClass="searchCntrl" placeholder="Enter Contract #"></asp:TextBox>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                        <div class="labelPad4">
                            Collection Start Date
                        </div>
                        <div class="value">
                            <div class="input-append date">
                                <asp:TextBox ID="txtReceivableStartDate" runat="server" ClientIDMode="Static" MaxLength="50"
                                    onclick="show_DateCalender('txtReceivableStartDate');" TabIndex="8" CssClass="dateinput"
                                    ReadOnly="true" placeholder="dd/mm/yyyy" onkeydown="javascript:return clearDates(event);"></asp:TextBox>
                                <span class="add-on" id="Span7" onclick="show_DateCalender('txtReceivableStartDate');" style="float: right"><i
                                    class="icon-th"></i></span>
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                        <div class="labelPad4">
                            Collection End Date
                        </div>
                        <div class="value">
                            <div class="input-append date">
                                <asp:TextBox ID="txtReceivableEndDate" runat="server" ClientIDMode="Static" MaxLength="50"
                                    onclick="show_DateCalender('txtReceivableEndDate');" TabIndex="10" CssClass="dateinput"
                                    ReadOnly="true" placeholder="dd/mm/yyyy" onkeydown="javascript:return clearDates(event);"></asp:TextBox>
                                <span class="add-on" id="Span9" onclick="show_DateCalender('txtReceivableEndDate');" style="float: right"><i
                                    class="icon-th"></i></span>
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                    </div>
                </div>
                <div class="clear"></div>
                <div class="fullpanel textalignright">
                    <a tabindex="9" class="btn-search-clear" onclick="clear_form_elements('divTopContainer');" onkeypress="clear_form_elements_ForTab(event,'divTopContainer');" href="javascript:void(0);">Clear</a>
                    <input type="button" id="btnSearch" tabindex="11" class="btn-search" onclick="javascript: return fn_GetSearchResult(0);"
                        value="Search" title="Search" />
                </div>
            </div>
            <a href='javascript:void(0);' class="closedivSmall" onclick="toggle_TopContainer();" title="Toggle Search Panel" tabindex="11"><i class="fa fa-chevron-up"></i></a>
        </div>
        <div class="maincontainer">
            <div class="listpagediv" id="divResult">
                <asp:GridView ID="grdResult" runat="server" ClientIDMode="Static" AutoGenerateColumns="false" Width="90%" CssClass="listdiv" DataKeyNames="TrnInvoiceID" OnRowDataBound="grdResult_RowDataBound">
                    <Columns>
                        <asp:BoundField DataField="CollectionID" HeaderText="Invoice ID" />
                        <asp:BoundField DataField="InvoiceID" HeaderText="Invoice ID" />
                        <asp:BoundField DataField="Remarks" HeaderText="Remarks" />

                        <asp:BoundField HeaderText="Sr." ItemStyle-HorizontalAlign="Center" />
                        <asp:TemplateField HeaderText="Action" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <a class="btn-edit" href="javascript:void(0);" onclick="return ShowEditDiv(<%#Eval("CollectionID") %>,this);" title="Edit"><i class="fa fa-pencil" title="Edit"></i></a>&nbsp;
                                <a class="btn-edit" href="javascript:void(0);" onclick="return DeleteRec(<%#Eval("CollectionID") %>,this);" title="Delete"><i class="fa fa-trash-o" title="Delete"></i></a>&nbsp;
                            </ItemTemplate>
                        </asp:TemplateField>

                        <asp:BoundField DataField="CompanyName" HeaderText="Company" />
                        <asp:BoundField DataField="ClientName" HeaderText="Client" />
                        <asp:BoundField DataField="ContractName" HeaderText="Contract" />
                        <asp:BoundField DataField="InvoiceNo" HeaderText="Invoice #" />
                        <asp:BoundField DataField="CollectionNo" HeaderText="Collection #" />
                        <asp:BoundField DataField="CollectionDate" HeaderText="Collection Date" DataFormatString="{0:dd/MM/yyyy}" ItemStyle-HorizontalAlign="Center" />
                        <asp:BoundField DataField="CollectionType" HeaderText="Collection Type" />
                        <asp:BoundField DataField="DrawnOnBank" HeaderText="Drawn Bank" />
                        <asp:BoundField DataField="CollectionRefNo" HeaderText="Ref. No." />

                        <asp:BoundField DataField="Amount" HeaderText="Amount" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:#,##0}" />
                        <asp:TemplateField HeaderText="TDS Amount" ItemStyle-HorizontalAlign="Right">
                            <ItemTemplate>
                                <%#TrynParse.parseDecimal(Eval("TDSAmount")) == 0 ? "-" : TrynParse.parseDecimal(Eval("TDSAmount")).ToString("#,##0") %>
                            </ItemTemplate>
                        </asp:TemplateField>

                        <asp:BoundField DataField="GrossAmount" HeaderText="Gross Amount" ItemStyle-HorizontalAlign="Right" DataFormatString="{0:#,##0}" />

                    </Columns>
                </asp:GridView>
            </div>

        </div>
    </div>
    <div class="modalopenConfirmDel modalopenInvoice" style="display: none;">
    </div>

    <div id="divInsertEdit" class="modalinvoice" onkeypress="javascript:return fireDefaultButton(event, 'btnSave')">
        <div class="form">
            <div class="innercontent">
                <div class="halfpanel">
                    <div class="row">
                        <div class="midium-label">
                            Invoice No&nbsp;&nbsp;<span class="red">*</span>
                        </div>
                        <div class="midium-value">
                            <div>
                                <asp:TextBox ID="txtAddInvoiceNo" runat="server" ClientIDMode="Static" Width="97%" onchange="fn_ChangeInvoiceNo();"
                                    MaxLength="50" placeholder="Enter Invoice No" CssClass="input" TabIndex="101"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfvtxtAddInvoiceNo" runat="server" Display="Dynamic" ClientIDMode="Static"
                                    ControlToValidate="txtAddInvoiceNo" ValidationGroup="vgSave" ErrorMessage="Enter Invoice No" InitialValue=""
                                    Width="90%"><span class="error">Enter invoice no</span></asp:RequiredFieldValidator>
                            </div>
                        </div>
                    </div>

                    <div class="clear"></div>
                    <div class="row">
                        <div class="midium-label">
                            Client
                        </div>
                        <div class="midium-value">
                            <div>
                                <asp:Label ID="lblAddClient" runat="server" ClientIDMode="Static"></asp:Label>
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                        <div class="midium-label">
                            Payment Mode
                        </div>
                        <div class="midium-value">
                            <div>
                                <asp:Label ID="lblAddPaymentMode" runat="server" ClientIDMode="Static"></asp:Label>
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                        <div class="midium-label">
                            Collection Date&nbsp;&nbsp;<span class="red">*</span>
                        </div>
                        <div class="midium-value">
                            <div class="input-append date">
                                <asp:TextBox ID="txtAddCollectionDate" runat="server" ClientIDMode="Static" MaxLength="50"
                                    onclick="show_DateCalender('txtAddCollectionDate');" TabIndex="102" CssClass="dateinput"
                                    ReadOnly="true" placeholder="dd/mm/yyyy" onkeydown="javascript:return clearDates(event);"></asp:TextBox>
                                <span class="add-on" id="Span2" onclick="show_DateCalender('txtAddCollectionDate');" style="float: right"><i class="icon-th"></i></span>
                            </div>
                            <asp:RequiredFieldValidator ID="rftxtAddCollectionDate" runat="server" Display="Dynamic" ClientIDMode="Static"
                                ControlToValidate="txtAddCollectionDate" ValidationGroup="vgSave" ErrorMessage="Enter Collection Date" InitialValue=""
                                Width="90%"><span class="error">Enter collection date</span></asp:RequiredFieldValidator>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                        <div class="midium-label">
                            Collection Type&nbsp;&nbsp;<span class="red">*</span>
                        </div>
                        <div class="midium-value">
                            <div>
                                <asp:DropDownList ID="cboAddCollectionType" ClientIDMode="Static" runat="server" TabIndex="104" CssClass="searchCntrl" Width="70%" onchange="fn_ChangeCollectionType()">
                                    <asp:ListItem Value="0" Text="[Select Collection Type]"></asp:ListItem>
                                    <asp:ListItem Value="Cheque" Text="Cheque"></asp:ListItem>
                                    <asp:ListItem Value="NEFT" Text="NEFT"></asp:ListItem>
                                    <asp:ListItem Value="RTGS" Text="RTGS"></asp:ListItem>
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator ID="rfvcboAddCollectionType" runat="server" Display="Dynamic" ClientIDMode="Static"
                                    ControlToValidate="cboAddCollectionType" ValidationGroup="vgSave" ErrorMessage="Select Company" InitialValue="0"
                                    Width="90%"><span class="error">Select collection type</span></asp:RequiredFieldValidator>
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                        <div class="midium-label">
                            Drawn On Bank&nbsp;&nbsp;<span class="red">*</span>
                        </div>
                        <div class="midium-value">
                            <div>
                                <asp:TextBox ID="txtAddDrawnOnBank" runat="server" ClientIDMode="Static" Width="97%"
                                    MaxLength="50" placeholder="Enter Drawn On Bank" CssClass="input" TabIndex="106"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfvtxtAddDrawnOnBank" runat="server" Display="Dynamic" ClientIDMode="Static"
                                    ControlToValidate="txtAddDrawnOnBank" ValidationGroup="vgSave" ErrorMessage="Enter Drawn On Bank" InitialValue=""
                                    Width="90%"><span class="error">Enter drawn on bank</span></asp:RequiredFieldValidator>
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                        <div class="midium-label">
                            Reference No.
                            &nbsp;&nbsp;<span class="red">*</span>
                        </div>
                        <div class="midium-value">
                            <div>
                                <asp:TextBox ID="txtAddRefNo" runat="server" ClientIDMode="Static" Width="97%"
                                    MaxLength="50" placeholder="Enter Reference No." CssClass="input" TabIndex="108"></asp:TextBox>
                                <asp:RequiredFieldValidator ID="rfvtxtAddRefNo" runat="server" Display="Dynamic" ClientIDMode="Static"
                                    ControlToValidate="txtAddRefNo" ValidationGroup="vgSave" ErrorMessage="Enter Reference No." InitialValue=""
                                    Width="90%"><span class="error">Enter reference no.</span></asp:RequiredFieldValidator>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="halfpanel">
                    <div class="clear"></div>
                    <div class="row">
                        <div class="label">
                            Company
                        </div>
                        <div class="midium-value">
                            <div>
                                <asp:Label ID="lblAddCompany" runat="server" ClientIDMode="Static"></asp:Label>
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                        <div class="label">
                            Contract
                        </div>
                        <div class="midium-value">
                            <div>
                                <asp:Label ID="lblAddContract" runat="server" ClientIDMode="Static"></asp:Label>
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                        <div class="label">
                            Payment Level
                        </div>
                        <div class="midium-value">
                            <div>
                                <asp:Label ID="lblPaymentLevel" runat="server" ClientIDMode="Static"></asp:Label>
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                        <div class="label">
                            Amount&nbsp;&nbsp;<span class="red">*</span>
                        </div>
                        <div class="midium-value">
                            <asp:TextBox ID="txtAddAmount" runat="server" ClientIDMode="Static" Width="97%" onchange="fn_CalculateGross();"
                                MaxLength="50" placeholder="Enter Amount" CssClass="input" TabIndex="103"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="rfvtxtAddAmount" runat="server" Display="Dynamic" ClientIDMode="Static"
                                ControlToValidate="txtAddAmount" ValidationGroup="vgSave" ErrorMessage="Enter Amount" InitialValue=""
                                Width="90%"><span class="error">Enter amount</span></asp:RequiredFieldValidator>
                            <asp:CustomValidator ID="cvtxtAddAmount" runat="server" ClientIDMode="Static" ControlToValidate="txtAddAmount"
                                ClientValidationFunction="fn_ValidateExpressionTextbox" ValidationGroup="vgSave" ValidateEmptyText="false" expressionid="NumDel"
                                Display="Dynamic" Width="90%"><span id="Span1" class="error"></span></asp:CustomValidator>
                        </div>
                    </div>
                    <div class="clear"></div>
                    <div class="row">
                        <div class="label">
                            TDS Deducted&nbsp;<span class="red">*</span>
                        </div>
                        <div class="value paddingtop7">
                            <asp:RadioButton runat="server" ID="rbTDSReceivedYes" ClientIDMode="Static" Text=" Yes" onchange="fn_ChangeViewTDS()"
                                GroupName="grpServiceTax" TabIndex="105" /><div style="width: 10px; float: left;">
                                    &nbsp;
                                </div>
                            <asp:RadioButton runat="server" ID="rbTDSReceivedNo" ClientIDMode="Static" Text=" No" onchange="fn_ChangeViewTDS()"
                                GroupName="grpServiceTax" TabIndex="105" />
                            <asp:CustomValidator ID="cvServiceTax" runat="server" ClientIDMode="Static" ClientValidationFunction="fn_ValidateTDSTax"
                                Width="100%" ValidationGroup="vgCollectionDetails" Display="Dynamic"><span style="width:100px" class="error">Select Yes or No</span></asp:CustomValidator>
                        </div>
                    </div>
                    <div class="clear">
                    </div>
                    <div class="row">
                        <div class="label paddingtop7">
                            TDS Amount&nbsp;<span class="red">*</span>
                        </div>
                        <div class="value">
                            <asp:TextBox ID="txtAddTDSAmount" ClientIDMode="Static" runat="server" TabIndex="107" Width="150px" onchange="fn_CalculateGross();"
                                CssClass="input" placeholder="TDS Amount"></asp:TextBox>
                            <asp:CustomValidator runat="server" ID="rfvtxtAddTDSAmount" Display="Dynamic" ValidationGroup="vgCollectionDetails" ClientIDMode="Static"
                                ClientValidationFunction="fn_ValidateTDSAmount"
                                ControlToValidate="txtAddTDSAmount" Width="100%">
                                                            <span class="error" style="width:140px">Enter amount</span>
                            </asp:CustomValidator>
                        </div>
                    </div>
                    <div class="clear">
                    </div>
                    <div class="row">
                        <div class="label paddingtop7">
                            Gross Amount
                        </div>
                        <div class="value paddingtop7">
                            <asp:Label ID="lblAddGrossAmount" runat="server" ClientIDMode="Static"></asp:Label>
                        </div>
                    </div>
                    <div class="clear">
                    </div>
                    <div class="row">
                        <div class="label paddingtop7">
                            Remarks
                        </div>
                        <div class="value">
                            <textarea rows="2" cols="30" id="txtAddRemarks" runat="server" clientidmode="Static" style="width: 100%" placeholder="Remarks" class="input" tabindex="109"></textarea>
                        </div>
                    </div>
                    <div class="clear">
                    </div>
                </div>
                <div class="clear"></div>
                <div class="pagefooter">
                    <center>
                        <input type="button" id="btnSave" onclick="javascript: return fn_SaveDetails();"
                            tabindex="110" value="Save" validationgroup="vgSave" class="btn-primary" />
                    </center>
                </div>
            </div>
        </div>
    </div>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="cntMain" runat="Server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="FootContent" runat="Server">
</asp:Content>

